/*
 * #%L
 * SwiftUICommonUtilities
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2011 - 2012 Linkwithweb
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * #L%
 */
/**
 * 
 */
package com.linkwithweb.products.swiftui.context;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.linkwithweb.products.swiftui.dataobject.FrameworkApplication;

/**
 * Used to store DB Insert/Update/Delete statements...
 * 
 * @author ashwin kumar
 * 
 */
public class DBUpdateStatement {
	private String tableName = "";
	private String statementType = "";
	private String updateStatement = "";
	private String datasourceName = "";
	FrameworkApplication application = null;
	private List arguments = Collections.EMPTY_LIST;
	private List columnNames = new ArrayList();;

	/**
	 * @return the tableName
	 */
	public String getTableName() {
		return tableName;
	}

	/**
	 * @param tableName
	 *            the tableName to set
	 */
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	/**
	 * @return the updateStatement
	 */
	public String getUpdateStatement() {
		return updateStatement;
	}

	/**
	 * @param updateStatement
	 *            the updateStatement to set
	 */
	public void setUpdateStatement(String updateStatement) {
		this.updateStatement = updateStatement;
	}

	/**
	 * @return the datasourceName
	 */
	public String getDatasourceName() {
		return datasourceName;
	}

	/**
	 * @param datasourceName
	 *            the datasourceName to set
	 */
	public void setDatasourceName(String datasourceName) {
		this.datasourceName = datasourceName;
	}

	/**
	 * @return the arguments
	 */
	public List getArguments() {
		return arguments;
	}

	/**
	 * @param arguments
	 *            the arguments to set
	 */
	public void setArguments(List arguments) {
		this.arguments = arguments;
	}

	/**
	 * @return the statementType
	 */
	public String getStatementType() {
		String statementType = "INSERT";
		if(StringUtils.containsIgnoreCase(getUpdateStatement(), "update")){
			statementType = "UPDATE";
		}else if(StringUtils.containsIgnoreCase(getUpdateStatement(), "DELETE")){
			statementType = "DELETE";
		}else if(StringUtils.containsIgnoreCase(getUpdateStatement(), "create ")){
			statementType = "CREATE";
		}
		
		return statementType;
	}

	/**
	 * @param statementType
	 *            the statementType to set
	 */
	public void setStatementType(String statementType) {
		this.statementType = statementType;
	}

	/**
	 * @return the application
	 */
	public FrameworkApplication getApplication() {
		return application;
	}

	/**
	 * @param application
	 *            the application to set
	 */
	public void setApplication(FrameworkApplication application) {
		this.application = application;
	}

	/**
	 * @return the columnNames
	 */
	public List getColumnNames() {
		return columnNames;
	}

	/**
	 * @param columnNames
	 *            the columnNames to set
	 */
	public void setColumnNames(List columnNames) {
		this.columnNames = columnNames;
	}

}
